using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using StructureMap;
using Impact.Infrastructure.Configuration;
using Impact.Infrastructure.Logging;
using Impact.Model.Service;
using Impact.UnitTests.Mocks;
using Impact.Infrastructure.Membership;
using Impact.Web.Foundation.MembershipProviders;

namespace Impact.UnitTests
{
    [TestFixture]
    public class TestFixtureBase
    {

        [TestFixtureSetUp]
        public void Setup()
        {

            StructureMapConfiguration.UseDefaultStructureMapConfigFile = false;

            // make the mock objects as singletons so we can get back to the same object
            // to set test values or read values the program wrote
            StructureMapConfiguration.BuildInstancesOf<IConfigProvider>().TheDefaultIsConcreteType<MockConfig>().AsSingletons();
            StructureMapConfiguration.BuildInstancesOf<ILogger>().TheDefaultIsConcreteType<MockLogger>().AsSingletons();
            StructureMapConfiguration.BuildInstancesOf<IMembershipService>().TheDefaultIsConcreteType<AspNetMembershipService>().AsSingletons();

            StructureMapConfiguration.BuildInstancesOf<IArticleService>().TheDefaultIsConcreteType<MockArticleService>().AsSingletons();
            StructureMapConfiguration.BuildInstancesOf<ICategoryService>().TheDefaultIsConcreteType<MockCategoryService>().AsSingletons();
            StructureMapConfiguration.BuildInstancesOf<IPageService>().TheDefaultIsConcreteType<MockPageService>().AsSingletons();
            StructureMapConfiguration.BuildInstancesOf<IPluginService>().TheDefaultIsConcreteType<MockPluginService>().AsSingletons();
            StructureMapConfiguration.BuildInstancesOf<ITagService>().TheDefaultIsConcreteType<MockTagService>().AsSingletons();
            StructureMapConfiguration.BuildInstancesOf<ISubscriberService>().TheDefaultIsConcreteType<MockSubscriberService>().AsSingletons();

        }

        [SetUp]
        public void TestSetup()
        {
            MockLogger logger = (MockLogger)ObjectFactory.GetInstance<ILogger>();
            logger.Messages.Clear();

        }

    }
}
